#pragma once

#include "Singleton.h"

#include <unordered_map>
#include <memory>
#include <mutex>

class CSession;

class UserManager : public Singleton<UserManager>
{
	friend class Singleton<UserManager>;

public:
	~UserManager();

	std::shared_ptr<CSession> getSession(int uid);
	void setUserSession(int uid, std::shared_ptr<CSession> session);
	void removeUserSession(int uid);

private:
	UserManager() = default;

private:
	std::mutex m_session_mtx;
	std::unordered_map<int, std::shared_ptr<CSession>> m_uid_to_session;	// 用户uid与session之间的映射
};

